import { createRouter, createWebHashHistory } from 'vue-router';
import type { RouteRecordRaw } from 'vue-router';

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: '/home/index', // 默认跳转到“总体情况”页面
  },
  {
    path: '/home',
    name: 'home',
    component: () => import('@/views/HomeView.vue'),
    children: [
      {
        path: 'index',
        name: 'index',
        component: () => import('@/views/index/index.vue'), // 总体情况
      },
      {
        path: 'tracking',
        name: 'tracking',
        component: () => import('@/views/firstIndex/tracking.vue'), // 计划跟踪
      },
      {
        path: 'statistics',
        name: 'statistics',
        component: () => import('@/views/firstIndex/statistics.vue'), // 问题统计
      },
      {
        path: 'rectification',
        name: 'rectification',
        component: () => import('@/views/firstIndex/rectification.vue'), // 整改成效
      },
      {
        path: 'resource',
        name: 'resource',
        component: () => import('@/views/firstIndex/resource.vue'), // 资源分布
      },
      {
        path: 'audit',
        name: 'audit',
        component: () => import('@/views/firstIndex/audit.vue'), // 审计覆盖
      },
    ]
  },
];

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes,
});

router.beforeEach((to, from, next) => {
  next();
});

export default router;
